#include "net/Acceptor.h"
#include "net/EventLoop.h"
#include "Base/Logger.h"

using namespace toym;
using namespace toym::net;

void newConnection(Socket sock, const InetAddress& peerAddr) {
    LOG_INFO << "newConnection(): from " << peerAddr.toIpPort();
    sock.write("how are you?\n");
}

int main() {
    LogPuter::setLevel(LogPuter::LogLevel::INFO);
    EventLoop loop;
    InetAddress addr(10077);
    Acceptor acceptor(&loop, addr);
    acceptor.setNewConnectionCallback(newConnection);
    acceptor.listen();
    loop.loop();
}